#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <sys/select.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <sys/un.h>

conectarPPDConConsola() {
#define SOCKET_MAX_BUFFER 512

int addrlen = sizeof(struct sockaddr_un);
char buffer[SOCKET_MAX_BUFFER];

int descriptor = socket(AF_UNIX, SOCK_STREAM, 0);
int remote_client;

struct sockaddr_un *local_address = malloc(sizeof(struct sockaddr_un));
struct sockaddr_un *remote_address = malloc(sizeof(struct sockaddr_un));

local_address->sun_family = AF_UNIX;
strncpy(local_address->sun_path, "/home/utn_so/miSocketUnix", sizeof(local_address->sun_path));
unlink("home/utn_so/miSocketUnix");

bind(descriptor, (struct sockaddr *)local_address, sizeof(struct sockaddr_un));

listen(descriptor, 1);

remote_client = accept(descriptor, (struct sockaddr *)remote_address, (void *)&addrlen);

recv(remote_client, buffer, SOCKET_MAX_BUFFER, 0);

close(descriptor);

free(local_address);
free(remote_address);

return EXIT_SUCCESS;

}
